<?php

namespace app\api\controller;


use think\Controller;
use think\Db;
use think\Session;
class Article extends Controller
{
    public $pagesize = 10;
    public $preurl="https://manager.scajxd.com";
    /**
     * 获取详情接口
     * @return \think\response\Json
     */
    public function info()
    {
        $id = trim(input("request.id"));//文章ID
        if (empty($id)) {
            $return = ['err' => 2, 'msg' => '参数错误', 'devMsg' => '获取失败，参数错误[id]'];
            return json($return);
        }
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            return json($return);
        }

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        return json($return);
    }


    public function companyInfo()
    {

        $id = 8;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            return json($return);
        }
        $info['content']=dealContentsForImagesE( $info['content'],$this->preurl);

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        return json($return);
    }

    public function userAgreement()
    {

        $id = 7;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            return json($return);
        }
        $info['content']=dealContentsForImages( $info['content'],$this->preurl);

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        return json($return);
    }

    public function userManual()
    {

        $id = 6;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            return json($return);
        }
        $info['content']=dealContentsForImages( $info['content'],$this->preurl);
        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        return json($return);
    }


    public function aboutUs()
    {

        $id = 5;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            return json($return);
        }
        $info['content']=dealContentsForImages( $info['content'],$this->preurl);
        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        return json($return);
    }











    public function companyInfo_web()
    {

        $id = 8;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            $this->assign('data', $return);
            return $this->fetch('edit');
        }

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        $this->assign('data', $return);
        return $this->fetch('edit');
    }

    public function userAgreement_web()
    {

        $id = 7;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            $this->assign('data', $return);
            return $this->fetch('edit');
        }

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        $this->assign('data', $return);
        return $this->fetch('edit');
    }

    public function userManual_web()
    {

        $id = 6;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            $this->assign('data', $return);
            return $this->fetch('edit');
        }

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        $this->assign('data', $return);
        return $this->fetch('edit');
    }


    public function aboutUs_web()
    {

        $id = 5;
        $model = new  \app\admin\model\Article();
        $info = $model->getDataForWhere(array('id' => $id));
        if (empty($info)) {
            $return = ['err' => 2, 'msg' => '信息不存在', 'devMsg' => ''];
            $this->assign('data', $return);
            return $this->fetch('edit');
        }

        $relationProductList = array();
        if ($info['relation_ids']) {
            $relationProductList = getProductListForIds($info['relation_ids'], 1, "*");
        }
        $info['relationProductLists'] = $relationProductList;
        $return = ['err' => 0, 'msg' => '获取成功', 'devMsg' => '获取成功', 'data' => $info];
        $this->assign('data', $return);
        return $this->fetch('edit');
    }
}
